<template>
  <basic-container>
    <basic-header title="员工管理"/>
    <apply-table :action="action" ref="table">
      <template slot="slot-idFrontUrl" slot-scope="{data}">
        <img class="picture" :src="data"/>
      </template>
      <template 
        slot-scope="{ row }"
        slot="applyMenu"
      >
        <el-button 
          plain
          :type="row.isPutAway ? 'danger' : 'success'"
          size="small"
          @click.stop="handleChange(row)"
        >重置密码</el-button>
      </template>
    </apply-table>
  </basic-container>
</template>
<script>
import ApplyTable from '@/components/ApplyTable'
import actionTypes from '@/const/action'
import { PromiseResetPassword } from '@/api/config'
export default {
  name: 'shop',
  components: { ApplyTable },
  data() {
    return {
      action: actionTypes.PERSONNEL_MANAGE
    }
  },
  methods: {
    handleChange(row) {
      this.$confirm('确认重置员工密码吗?', '提示',{
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        PromiseResetPassword(row.id).then(() => {
          this.$message({
            type: 'success',
            message: '重置成功！'
          })
          this.$refs.table.RefreshData()
        }).catch(error => {
          this.$meesage({
            type: 'error',
            message: error
          })
        })
      })

    }
  }
}
</script>

